﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Win32;
using System.IO;

namespace WpfLussen
{
	/// <summary>
	/// Interaction logic for Window1.xaml
	/// </summary>
	public partial class Window1 : Window
	{
		private OpenFileDialog openFileDialog = null;
		public Window1()
		{
			InitializeComponent();
			openFileDialog = new OpenFileDialog();
			openFileDialog.FileOk += openFileDialogFileOk;
			
		}

		private void toonGetallen_Click(object sender, RoutedEventArgs e)
		{
			int i = 0;
			while (i < 10)
			{
				i++;
				if (i == 8) continue;
				list.Items.Add(i);
			}
		}

		private void btnLeegMaken_Click(object sender, RoutedEventArgs e)
		{
			list.Items.Clear();
		}

		private void btnOpenBestand_Click(object sender, RoutedEventArgs e)
		{
			openFileDialog.ShowDialog();
		}

		private void openFileDialogFileOk(object sender, System.ComponentModel.CancelEventArgs e)
		{
			string fullPathname = openFileDialog.FileName;
			FileInfo src = new FileInfo(fullPathname);
			txtBestand.Text = src.Name;

			TextReader reader = src.OpenText();
			// hier komt de while lus
			string line = reader.ReadLine();
			while (line != null)
			{
				list.Items.Add(line);
				line = reader.ReadLine();
			}
			// einde while lus

			reader.Close();
		}
	}
}
